import Vue from 'vue'
import Router from 'vue-router'
import login from '@/components/login'
import home from '@/components/home'
import goods from '@/components/goods/goods';
import come from '@/components/come';
import warehouse from "@/components/warehouse/warehouse";
import company from "@/components/company/company";
import outstock from "@/components/outstock/outstock";
import instock from "@/components/instock/instock";
import bill from "@/components/bill/bill";
import view from "@/components/view/view";
Vue.use(Router)


const router = new Router({
  routes: [
    { path: '/', redirect: '/login'},
    { path: '/login', component: login },
    {
      path: '/home',
      component: home,
      redirect: '/come',
      children :[
        {path: '/come', component: come},
        {path: '/goods', component: goods},
        {path: '/warehouse', component: warehouse},
        {path: '/company', component: company},
        {path: '/outstock', component: outstock},
        {path: '/instock', component: instock},
        {path: '/bill', component: bill},
        {path: '/view', component: view},
      ]
    }
  ]
})

//挂载路由守卫
router.beforeEach((to, from, next) => {
  
  if (to.path === '/login') return next();
  next()
})

export default router
